package cn.getech.data.development.sink.jdbc.dialect

import java.util.Optional

import org.apache.flink.connector.jdbc.dialect.JdbcDialect
import org.apache.flink.connector.jdbc.internal.converter.JdbcRowConverter
import org.apache.flink.table.types.logical.RowType

// 未使用
class ClickHouseDialect extends JdbcDialect {
  /**
   * Check if this dialect instance can handle a certain jdbc url.
   * val driver = "ru.yandex.clickhouse.ClickHouseDriver"
   * val JDBCUrl = "jdbc:clickhouse://bigdata-test-4:8123/default"
   * @param url the jdbc url.
   * @return True if the dialect can be applied on the given jdbc url.
   */
  override def canHandle(url: String): Boolean = url.startsWith("jdbc:clickhouse:")

  override def defaultDriverName(): Optional[String] = Optional.of("ru.yandex.clickhouse.ClickHouseDriver")

  override def quoteIdentifier(identifier: String): String = "`" + identifier + "`"

  override def getUpsertStatement(tableName: String, fieldNames: Array[String], uniqueKeyFields: Array[String]): Optional[String] = Optional.of(getInsertIntoStatement(tableName, fieldNames))

  override def dialectName(): String = ???

  override def getRowConverter(rowType: RowType): JdbcRowConverter = ???
}
